A Python package for automated Bechdel test analysis of movie scripts.
pip install btest
from btest.core.analyzer import BechdelAnalyzer
# Create analyzer instance
analyzer = BechdelAnalyzer()
# Analyze a movie directly by title
result = analyzer.analyze_movie("The Matrix")
if result:
print(f"Passed Bechdel test: {result.passes_test}")
print(f"Female characters: {[char.name for char in result.female_characters]}")
if not result.passes_test:
print(f"Failure reasons: {result.failure_reasons}")
else:
print("Movie script not found")
# Or analyze a local script file
result = analyzer.analyze_script_file("path/to/script.txt")
# Print results
print(f"Passed Bechdel test: {result.passes_test}")
print(f"Female characters: {[char.name for char in result.female_characters]}")
if not result.passes_test:
print(f"Failure reasons: {result.failure_reasons}")
The package includes a built-in movie script database from the Cornell Movie Dialog Corpus. Scripts are automatically downloaded and cached locally when needed.
To analyze a movie:
analyze_movie()If a script isn't found in the database, you can still analyze a local script file using analyze_script_file().
The package can use Ollama for improved analysis:
ollama pull llama2
The LLM features provide:
If Ollama is not available, the package falls back to rule-based analysis.
LLM features can be customized through environment variables:
OLLAMA_MODEL: Choose a different model (default: "llama2")OLLAMA_HOST: Connect to a remote Ollama instance# Clone the repository
git clone https://github.com/yourusername/btest.git
cd btest
# Create a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
Contributions are welcome! Please feel free to submit a Pull Request.
[Your chosen license]